package com.itheima.udp;

import java.io.IOException;
import java.net.*;
import java.util.Scanner;

public class SendDemo {
    public static void main(String[] args) throws IOException {
        DatagramSocket ds = new DatagramSocket();
        Scanner sc = new Scanner(System.in);
        while (true) {
            String s = sc.next();
            if (s.equals("886")) {
                break;
            }
            //将获取的字符串转换成byte存入一个byte类型的数组中
            byte[] bys = s.getBytes();
            //将数据打包
            DatagramPacket dp = new DatagramPacket(bys, bys.length, InetAddress.getByName("127.0.0.1"), 10000);
            ds.send(dp);
        }
        ds.close();
    }
}
